/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"gctl/internal/sql2pb"
	"github.com/spf13/cobra"
)

// sql2pbCmd represents the sql2pb command
var sql2pbCmd = &cobra.Command{
	Use:   "sql2pb",
	Short: "A brief description of your command",
	Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
	Run: sql2pb.Sql2PBRoute,
}

var (
	dbType          string
	host            string
	port            int
	user            string
	password        string
	schema          string
	table           string
	serviceName     string
	packageName     string
	goPackageName   string
	ignoreTableStr  string
	ignoreColumnStr string
	fieldStyle      string
)

func init() {
	rootCmd.AddCommand(sql2pbCmd)

	sql2pbCmd.PersistentFlags().StringVar(&dbType, "db", "mysql", "数据库类型")
	sql2pbCmd.PersistentFlags().StringVar(&host, "host", "localhost", "地址")
	sql2pbCmd.PersistentFlags().IntVar(&port, "port", 3306, "端口号")
	sql2pbCmd.PersistentFlags().StringVar(&user, "user", "root", "用户名")
	sql2pbCmd.PersistentFlags().StringVar(&password, "password", "", "密码")
	sql2pbCmd.PersistentFlags().StringVar(&schema, "schema", "", "数据库名称")
	sql2pbCmd.PersistentFlags().StringVar(&table, "table", "*", "表模式，可以使用`,`多表或单表 ")
	sql2pbCmd.PersistentFlags().StringVar(&serviceName, "service_name", schema, "protobuf文件名称，默认数据库名称")
	sql2pbCmd.PersistentFlags().StringVar(&packageName, "package", schema, "the protocol buffer package. defaults to the database schema.")
	sql2pbCmd.PersistentFlags().StringVar(&goPackageName, "go_package", "", "the protocol buffer go_package. defaults to the database schema.")
	sql2pbCmd.PersistentFlags().StringVar(&ignoreTableStr, "ignore_tables", "", "a comma spaced list of tables to ignore")
	sql2pbCmd.PersistentFlags().StringVar(&ignoreColumnStr, "ignore_columns", "", "a comma spaced list of mysql columns to ignore")
	sql2pbCmd.PersistentFlags().StringVar(&fieldStyle, "field_style", "sqlPb", "gen protobuf field style, sql_pb | sqlPb")
	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// sql2pbCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// sql2pbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
